<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <form name="f1">
      <p>姓名 <input id="username" type="text" name="name" value="jack" /></p>
      <button name="saveBtn" type="button">提交</button>
    </form>
    <script>
      setTimeout(() => {
        document.f1.name.value = "lili";
      }, 3000);
      document.f1.saveBtn.onclick = function () {
        console.log(document.f1.name.value);
        // console.log(document.getElementById("username").value);
      };
    </script>
  </body>
</html>
